$(function(){
	var images=[
		"work1.png",
		"work2.png",
		"work3.png",
		"work4.png",
		"work5.png",
	];
	$("#work_img").bind("click",function(){
		$("#work_img_big").attr("style","background:url("+(this.src).replace(0,14)+") no-repeat");
		$("#work_img_big").css("display","block");
	});
	$("#work_img_big").bind("click",function(){
		$("#work_img_big").attr("style","background:url() no-repeat");
		$("#work_img_big").css("display","none");
	});
	var index = 1;
	function func(){
		$("#work_img").attr("src","img/"+images[index]);
		switch(index){
			case 0:$("#work_text").html("进入主页");break;
			case 1:$("#work_text").html("点击头部一下");break;
			case 2:$("#work_text").html("点击身体一下");break;
			case 3:$("#work_text").html("双击");break;
			case 4:$("#work_text").html("更换人物");break;
		}
		index++;
		if(index==5){
			index=0;
		}
	}
	var timer = setInterval(func,1500);
	$("#work_img").hover(
		function(){
			clearInterval(timer);
		},
		function(){
			timer = setInterval(func,1500);
		}
	);
	$("#toTop").bind("click",function(){
		$('html,body').animate({scrollTop: 0},1000); 
	});
	$(window).bind("scroll", function(){
	    var top = $(this).scrollTop(); // 当前窗口的滚动距离
	    if(top==0){
	    	$("#toTop").css("opacity","0");
	    }
	    if(top>0){
	    	$("#toTop").css("opacity","1");
	    }
	    if(top>500){
	       $(".html").width("90%");
	       $(".ui").width("70%");
	       $(".study").width("80%");
	       $(".javascript").width("80%");
	    }
	    if(top<500||top>1440){
	    	 $(".html").width("0%");
	       $(".ui").width("0%");
	       $(".study").width("0%");
	       $(".javascript").width("0%");
	    }
	    console.log(top);
	});
});
window.onbeforeunload=function(){
	$('html,body').animate({scrollTop: 0},0); 
}